#include <sys/types.h>
#include <unistd.h>
#include <iostream>
using namespace std;
int main()
{
    pid_t child_pid;
    int i = 1;
    cout << "the main program process ID is " << getpid() << endl;
    child_pid = fork();
    if (child_pid != 0)
    {
        cout << "this is the parent process, with id " << getpid() << " and i = " << i << endl;
        cout << "the child process ID is " <<child_pid<< endl;
    }
    else
    {
        sleep(5);
        i++;
        cout << "this is the child process, with id " << getpid() << " and i = " << i << endl;
        cout << "the parent process ID is " << getppid() << endl;
    }
    return 0;
}